// app.js
import './utils/utils'
import './utils/http'
App({
  globalData: {},
  onLaunch() {
    this.getToken('token')
    this.getToken('refresh_token')
  },

  // 保存状态码
  setStutasCode(statusCode) {
    wx.setStorageSync('statusCode', statusCode)
    this.statusCode = statusCode

  },
  // 获取状态码
  getStatusCode() {
    wx.getStorageSync({
      key: 'statusCode',
      success: (e) => {
        // console.log('状态码', e);
        console.log(statusCode);
      }
    })
  },
  //保存token
  setToken(token, refresh_token) {
    token = 'Bearer ' + token
    refresh_token = 'Bearer ' + refresh_token
    wx.setStorageSync('refresh_token', refresh_token)
    wx.setStorageSync('token', token)
    this.token = token
    this.refresh_token = refresh_token

  },

  getToken(key) {
    wx.getStorage({
      key,
      success: ({
        data
      }) => {
        this[key] = data
        // console.log(this.token);
      }
    })
  }
})